//闈炶浆鍙戠畝鍘嗛瑙堢殑js
$(function(){
	//鏌ョ湅鑱旂郴鏂瑰紡缁戝畾浜嬩欢
	$("#resume_preview_btmbar .look_contact").bind("click",function(){
		var deliverId = $("#deliver_id").val();
		$.ajax({  
	        type : "get",  
	        async:false,  
	        url : rctx+"/contact/show.json",  
	        data:{id:deliverId},
	        dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟  
	    }).done(function(result){
			if(result.state == "1"){
				top.location.href=top.location.href;
			}else if( result.state == 301 ){
				$.colorbox({inline:true, href:$("#reachLimit"),title:"寰呭畾绠�巻鍒拌揪涓婇檺"});
			}else{
				$.colorbox({inline:true, href:$("#statusChange"),title:"绠�巻鐘舵�鍙樺寲"});
			};
		 });
	});
	$('#reachLimit .btn').click(function(){
		$.colorbox.close();
	});
	//绠�巻鐘舵�鍙戠敓鏀瑰彉鏃剁偣鍑荤‘瀹氭垨鑰呭叧闂埛鏂伴〉闈�
	$('#statusChange .btn').click(function(){
		top.location.href=top.location.href;
	});
	$('#colorbox').on('click','#cboxClose',function(){
		if($(this).siblings('#cboxLoadedContent').children('div').attr('id') == 'statusChange'){
			top.location.href=top.location.href;
		}
	});
//===================
	 //绾夸笂閫氱煡闈㈣瘯寮圭獥鏁版嵁
	

//===================	wrote  by nancy
	//杞彂绠�巻寮圭獥
	$('.resume_forwards').bind('click',function(){
		$(this).children('dl').hide();
		var positionName = $(this).attr("data-positionName");
		var resumeKey = $(this).attr("data-resumeKey");
		var positionId = $(this).attr("data-positionId");
		var deliverId = $(this).attr("data-deliverId");
		var title = "锛堢畝鍘嗘潵鑷媺鍕撅級"+$(this).attr("data-positionName") + "锛� + $(this).attr("data-resumeName");
		var content = '浠ヤ笅鏄簲鑱樷�'+$(this).attr("data-positionName")+'鈥濈殑绠�巻銆傛垜宸叉煡闃咃紝璇锋偍璇勪及涓�笅銆�鑻ヨ鍚堥�锛屾垜浠皢瀹夋帓闈㈣瘯锛岃阿璋紒';

		var lastForwardEmail = "";
		
		// 鏌ヨ涓婁竴娆¤浆鍙戣褰曚腑鐨勬敹浠朵汉銆佷富棰樸�姝ｆ枃
		$.ajax({
			type:'GET',
			async:false,
			url:rctx + '/forward/lastForwardRecord.json',
			data:{
				"deliverId": deliverId
			},
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
		    jsonp: "jsoncallback",//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟  
		    success:function(result){
				if(null != result){
					if(result.state == 101 || result.state == 102){
						console.log(result.message);
					} else if(result.state == 1){
						title = result.content.data.lastForwardRecord.title;
						content = result.content.data.lastForwardRecord.content;
						lastForwardEmail = result.content.data.lastForwardRecord.recipients;
						
				}
				$('#forwardResumeForm input[name="recipients"]').val(lastForwardEmail);
				$('#forwardResumeForm input[name="title"]').val(title).removeClass('error').removeClass('valid');
				$('#forwardResumeForm textarea[name="content"]').val(content).removeClass('error').removeClass('valid');					}
			}
		});	
		
		$('#forwardResumeForm input[name="positionName"]').val(positionName);
		$('#forwardResumeForm input[name="resumeKey"]').val(resumeKey);
		$('#forwardResumeForm input[name="positionId"]').val(positionId);
		$('#forwardResumeForm input[name="deliverId"]').val(deliverId);
		$('#forwardResumeForm span.error').remove();
		placeholderFn();
		//autocomplete email
		//suggestEmail('recipients');
		
		$.colorbox({inline:true, href:$("#forwardResume"),title:"杞彂绠�巻"});
	});
	//杞彂閭欢寮圭獥锛氳緭鍏ラ偖浠舵彁绀�
	function suggestEmail(input){
		var availableTags = '';
		$.ajax({
			type:'GET',
			async:false,
			url:rctx + '/forward/forwardSuggest.json',
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟  
		}).done(function(result){
			availableTags = result.content;
		});
		
		$('#'+ input ).autocomplete({
			 source:  function( request, response ) {
		          response( $.ui.autocomplete.filter(
		            availableTags, extractLast( request.term ) ) );
		        },
		        focus: function() {
		          return false;
		        },
		        select: function( event, ui ) {
		          var terms = split( this.value );
		          terms.pop();
		          terms.push( ui.item.value );
		          terms.push( "" );
		          this.value = terms.join( "; " );
		          return false;
		        }
		});
	}
	
	//杞彂绠�巻琛ㄥ崟鎻愪氦
	$('#forwardResumeForm').validate({
       /* onkeyup: false,
    	focusCleanup:true,*/
        rules: {
        	recipients: {
    	    	required: true,
    	    	moreEmail:true,
    	    	maxlength:100
    	   	},
    	   	title: {
    	    	required: true,
    	    	maxlength:200
    	   	},
    	   	content: {
    	    	required: true,
    	    	maxlength:500
    	   	}
    	},
    	messages: {
    		recipients: {
    	    	required: "璇疯緭鍏ユ敹浠朵汉鐨勯偖浠跺湴鍧�,
    	    	moreEmail:"璇疯緭鍏ユ湁鏁堢殑鏀朵欢浜虹殑閭欢鍦板潃锛屾渶澶�涓紝骞剁敤;闅斿紑",
    	    	maxlength:"璇疯緭鍏�00瀛椾互鍐呯殑閭鍦板潃"
    	   	},
    	   	title: {
    	    	required: "璇疯緭鍏ヤ綘鐨勪富棰�,
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勪富棰�
    	   	},
    	   	content: {
    	    	required: "璇疯緭鍏ヤ綘鐨勬鏂�,
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勬鏂�
    	   	}
    	},
    	submitHandler:function(form){
    		var recipients = $('input[name="recipients"]',form).val();
    		var title = $('input[name="title"]',form).val();
    		var content = $('textarea[name="content"]',form).val();
    		var deliverId = $('input[name="deliverId"]',form).val();
    		var resubmitToken = $('#resubmitToken').val();
            $.ajax({
            	type:'POST',
            	url:rctx+'/forward/forward.json',
            	data:{
            		recipients:recipients,
            		title:title,
            		content:content,
            		deliverId:deliverId,
	        		resubmitToken:resubmitToken
            	},
            	dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
    	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
            }).done(function(result) {
            	if(null != result.resubmitToken && '' != result.resubmitToken){
            		$('#resubmitToken').val(result.resubmitToken);
            	}
				if( result.state == 1 ){
				
					$.colorbox({inline:true, href:$("#forwardResumeSuccess"),title:"杞彂绠�巻"});
				}else{
					$('#forwardResumeError').html(result.msg).addClass('error');
					$('#forwardResumeForm .beError').html(result.msg).show();
				}
            }); 
        }  
	});
	//杞彂鎴愬姛寮圭獥鐨勭‘璁ゆ寜閽�
	$('#forwardResumeSuccess .btn ,#refuseMailSuccess .btn').click(function(){
		$.colorbox.close();
	});
	//绠�巻棰勮涓嬭浇寮圭獥
	$('.resume_download2').bind('click',function(){
		$.colorbox({inline:true, href:$("#downloadOnlineResume"),title:"涓嬭浇绠�巻"});
	});
//===================	wrote  by nancy	
	$('.resume_refuse').bind('click',function(){
		$('#refuse_select_templete').removeClass('select_focus');
		$('#refuseMailForm .boxUpDown').hide();
		var deliverId = $(this).attr("data-deliverId");
		$('#refuseMailForm input[name="deliverId"]').val(deliverId);
		$.ajax({
			url:rctx+'/templates/getRefuseTemplates.json',
			type:'POST',
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟 
		}).done(function(result){
			var template = eval("(" + result.content.data.templates[0].templateContent + ")");
			if(result.state == 1){
				$('#refuseMailForm input#refuse_select_templete').val(template.alis);
				$('#refuseMailForm textarea').val(template.content).removeClass('error').removeClass('valid');
				$('#refuseMailForm span.error').remove();
			}
			$.colorbox({inline:true, href:$("#confirmRefuse"),title:"纭绠�巻涓嶅悎閫�});
		});
	});
	//涓嶅悎閫傞〉闈㈢偣鍑婚�鎷╂ā鏉�
	var refuseObj = {};
	$('.selectRefuse').click(function(){
		$('#refuseMailForm span.error').hide();
		$.ajax({
			type:'post',
			url:rctx+'/templates/getRefuseTemplates.json',
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟 
		}).done(function(result){
			if(result.state == 1){
				var alisLength = result.content.data.templates.length;
				$('#refuse_select_templete').parents('span').siblings('div.boxUpDown').show();
				var str = '';
				for(var i=0;i<alisLength;i++){
					templates = result.content.data.templates[i];
					str += '<li>'+templates.alis+'</li>' ;
					refuseObj[templates.alis] =eval("(" + templates.templateContent + ")");
				}
				$('#refuse_select_templete').parents('span').siblings('div.boxUpDown').find('ul').html(str);
				$('#refuse_select_templete').addClass('select_focus');
			}else{
				alert(result.message);
			}
		});
	});
	
	//涓嶅悎閫傞�鎷╂ā鏉�
	$('.select_templete2 ul').on('click','li',function(){
		var val =  $(this).text();
		for( var alis in refuseObj ){
			if(alis == val){
				content = refuseObj[val];
				$('#refuse_select_templete').val(alis);
				$('#refuseMailForm textarea[name="content"]').val(content.content);
				$('input#refuse_select_templete').removeClass('select_focus');
				$(this).parents('div.boxUpDown').hide();				
				return false;
			}
		}
	});
	$('#confirmRefuse').click(function(){
		var flag = $('.boxUpDown').hasClass('dn');
		if(flag){
			$('.boxUpDown').hide();
			$('#refuse_select_templete').removeClass('select_focus');
		}
	});
	/*鎷掔粷閭欢楠岃瘉*/
	$('#refuseMailForm').validate({
       /* onkeyup: false,
    	focusCleanup:true,*/
        rules: {
        	content: {
    	    	required: true,
    	    	maxlength:200
    	   	}
    	},
    	messages: {
    		content: {
    	    	required: "璇疯緭鍏ヤ綘鐨勯偖浠跺唴瀹�,
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勯偖浠跺唴瀹�
    	   	}
    	},
    	submitHandler:function(form){
    		$(form).find(":submit").attr("disabled", "disabled");
    		var content = $('textarea[name="content"]',form).val();
    		var deliverId = $('input[name="deliverId"]',form).val();
    		var resubmitToken = $('#resubmitToken').val();
            $.ajax({
            	url:rctx+'/refuse/hrRefuse.json',
            	type:'POST',
            	data:{
            		content:content,
            		deliverIds:deliverId,
	        		resubmitToken:resubmitToken
            	},
            	dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
    	        jsonp: "jsoncallback",//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
    	        beforeSend: function(){
    	        	$(form).find(":submit").attr("disabled", "disabled");
    			}
            }).done(function(result) {
        		if(null != result.resubmitToken && '' != result.resubmitToken){
            		$('#resubmitToken').val(result.resubmitToken);
            	}
        		if(result.state == 5 ){
        			if($("#inappropriateCheck").attr("checked")){
        				closenlraf(true,"inappropriateCheck");
        				window.opener='';
            			window.close();
        			}else{
        				closenlraf(false,"inappropriateCheck");
        				top.location.href=top.location.href;
        			}
        			/*$.colorbox({inline:true, href:$("#refuseMailSuccess"),title:"纭绠�巻涓嶅悎閫�});*/
        			
    			}else if(result.state == 3){
					$.colorbox({inline:true, href:$("#statusChange"),title:"绠�巻鐘舵�鍙樺寲"});
    				
				}else{
    				alert(result.message);
    			}
        		$(form).find(":submit").attr("disabled", false);
            }); 
        }
	});
	//鍒涘缓cookie
	function closenlraf(a,name){
		ctx = $.trim(ctx).substring(7);
		if(a){
			$.cookie(name,"true",{path:"/",expires:30,domain:ctx});
		}else{
			$.cookie(name,"true",{path:"/",expires:0,domain:ctx});
		}
	}
	
	$('#refuseMailSuccess .btn').click(function(){
		//$.colorbox.close();
		top.location.href=top.location.href;
	}); 
	
	//鍙栨秷鍏抽棴寮圭獥
	$(".emial_cancel").bind("click",function(){
		$.colorbox.close();
		parent.jQuery.colorbox.close();		
	});
//========================
	 //绾夸笂閫氱煡闈㈣瘯寮圭獥鏁版嵁
	$('.resume_notice').click(function(){
		$('#noticeInterviewForm input[name="interTime"]').val('');
		$('#notice_select_templete').removeClass('select_focus');
		$('#noticeInterview .boxUpDown').hide();
		 var deliverId = $(this).attr('data-deliverId');
		 var linkEmail2 = $(this).attr('data-email');
		 var positionName = $(this).attr('data-positionName');
		 $('#noticeInterview input[name="deliverId"]').val(deliverId);
		 var companyName= $(this).attr('data-company');
		$.ajax({
	        async:false,  
			type:'post',
			url:rctx+'/templates/getInterviewTemplates.json',
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟  
		}).done(function(result){
			var template = eval("(" + result.content.data.templates[0].templateContent + ")");
			if(result.state == 1){
				$('#noticeInterview input[name="email"]').val(linkEmail2);
				$('#noticeInterview input[name="selectTemplate"]').val(template.alis);
				$('#noticeInterview input[name="subject"]').val(companyName+"锛�+positionName+"闈㈣瘯閫氱煡").removeClass('error').removeClass('valid');
				$('#noticeInterview input[name="interAdd"]').val(template.interviewAddress).removeClass('error').removeClass('valid');
				$('#noticeInterview input[name="linkPhone"]').val(template.linkPhone).removeClass('error').removeClass('valid');
				$('#noticeInterview input[name="linkMan"]').val(template.linkMan);
				$('#noticeInterview textarea[name="content"]').val(template.content);
				$('#noticeInterview input[name="positionName"]').val(result.content.positionName);
				$('#noticeInterview input[name="companyName"]').val(result.content.companyName);
				$('#noticeInterview span.error').remove();
				$.colorbox({inline:true, href:$("#noticeInterview"),title:"閫氱煡闈㈣瘯"});
			}else{
				alert(result.message);
			};
		}); 
	});	
	var noticeObj = {};
	//鍙戦�闈㈣瘯閫氱煡閫夋嫨妯℃澘
	$('.notice_templete').click(function(){
		$('#noticeInterviewForm span.error').hide();
		$.ajax({
			type:'post',
			url:rctx+'/templates/getInterviewTemplates.json',
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
		}).done(function(result){
			if(result.state == 1){
				var alisLength = eval("(" + result.content.data.templates.length + ")");
				$('#notice_select_templete').parents('span').siblings('div.boxUpDown').show();
				var str = '';
				for(var i=0;i<alisLength;i++){
					var templates = eval("(" + result.content.data.templates[i].templateContent + ")");
					str += '<li>'+templates.alis+'</li>' ;
					noticeObj[templates.alis] = templates;
				}
				$('#notice_select_templete').parents('span').siblings('div.boxUpDown').find('ul').html(str);
				$('#notice_select_templete').addClass('select_focus');
			}else{
				alert(result.message);
			}
		});
	});
	
	/*棰勮閫氱煡闈㈣瘯閭欢*/
	$('#noticeInterview .emailPreview').bind('click',function(){
		var name = $('#noticeInterview input[name="email"]').val();
		var email = $('#noticeInterviewForm input[name="email"]').val();
		var subject = $('#noticeInterviewForm input[name="subject"]').val();
		var interTime = $('#noticeInterviewForm input[name="interTime"]').val();
		var interAdd = $('#noticeInterviewForm input[name="interAdd"]').val();
		var linkMan = $('#noticeInterviewForm input[name="linkMan"]').val();
		var linkPhone = $('#noticeInterviewForm input[name="linkPhone"]').val();
		var content = $('#noticeInterviewForm textarea[name="content"]').val();
		var pattern=/(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^[0-9]{3,4}\-[0-9]{7,8}\-[0-9]{3,5}$)|(^[0-9]{7,8}\-[0-9]{3,5}$)|(^\([0-9]{3,4}\)[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{7,8}\-[0-9]{3,5}$)|(^0{0,1}[13|15|18|14|17]{2}[0-9]{9}$)/;
		content = content.replace("/\r\n/g","<br>");
		$('#noticeInterviewPreview .f18').html(subject);
        $('#noticeInterviewPreview .c9 span').html(email);
		var emailText = name + '锛屾偍濂斤細<br />鎮ㄧ殑绠�巻宸查�杩囨垜浠殑绛涢�锛屽緢楂樺叴閫氱煡鎮ㄥ弬鍔犳垜浠殑闈㈣瘯銆�br /><br />'+
						'闈㈣瘯鏃堕棿锛�+interTime+'<br />闈㈣瘯鍦扮偣锛� + interAdd + '<br />';
		if(linkMan != ''){
			emailText += '鑱旂郴浜猴細'+linkMan +'<br />';
		}
		emailText += '鑱旂郴鐢佃瘽锛�+linkPhone;
		if(content){
			emailText += '<br /><br />' + content;
		}
        $('#emailText').html(emailText);
        var hasError = false;
        if(subject =='' || $('#noticeInterviewForm input[name="subject"]').hasClass('error')){
        	hasError = true;
        }
        if(interTime =='' || $('#noticeInterviewForm input[name="interTime"]').hasClass('error')){
        	hasError = true;
        }
        if(interAdd =='' || $('#noticeInterviewForm input[name="interAdd"]').hasClass('error')){
        	hasError = true;
        }
        if(linkPhone =='' || $('#noticeInterviewForm input[name="linkPhone"]').hasClass('error')){
        	hasError = true;
        }
        if($('#noticeInterviewForm textarea[name="content"]').hasClass('error')){
        	hasError = true;
        }
        if(hasError){
        	$('#noticeInterviewPreview .btn').hide();
        }else{
        	$('#noticeInterviewPreview .btn').show();
        }
        $.colorbox({inline:true, href:$("#noticeInterviewPreview"),title:"閫氱煡闈㈣瘯"});
	});
	//閫氱煡闈㈣瘯閫夋嫨妯℃澘
	$('.select_templete ul').on('click','li',function(){
		var val =  $(this).text();
		var content = $(this).parents('form#noticeInterviewForm').find('textarea').val();
		for( var alis in noticeObj ){
			if(alis == val){
				content = noticeObj[val];
				$('#notice_select_templete').val(alis);
				$('#noticeInterviewForm textarea[name="content"]').val(content.content);
				$('#noticeInterviewForm input[name="linkPhone"]').val(content.linkPhone);
				$('#noticeInterviewForm input[name="linkMan"]').val(content.linkMan);
				$('#noticeInterviewForm input[name="interAdd"]').val(content.interviewAddress);
				$('input#notice_select_templete').removeClass('select_focus');
				$(this).parents('div.boxUpDown').hide();				
				return false;
			}
		}
	});
	$('#noticeInterview').click(function(){
		var flag = $('.boxUpDown').hasClass('dn');
		if(flag){
			$('.boxUpDown').hide();
			$('#notice_select_templete').removeClass('select_focus');
		}
	});
	/*閫氱煡闈㈣瘯楠岃瘉*/
	$('#noticeInterviewForm').validate({
        /*onkeyup: false,
    	focusCleanup:true,*/
        rules: {
        	subject: {
    	    	required: true,
    	    	maxlength:200
    	   	},
    	   	interTime: {
    	    	required: true
    	   	},
    	   	interAdd: {
    	    	required: true,
    	    	maxlength:200
    	   	},
    	   	linkMan:{
    	   		required: false,
    	   		//add nancy
    	   		rangelength: [2,16]
    	   	},
    	   	linkPhone: {
    	    	required: true,
    	    	isTel:true,
    	    	maxlength:30
    	   	},
    	   	content:{
    	   		required: false,
    	    	maxlength:500
    	   	}
    	},
    	messages: {
    		subject: {
    	    	required: "璇疯緭鍏ヤ綘鐨勪富棰�,
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勪富棰�
    	   	},
    	   	interTime: {
    	    	required: "璇疯緭鍏ヤ綘鐨勯潰璇曟椂闂�
    	   	},
    	   	interAdd: {
    	    	required: "璇疯緭鍏ヤ綘鐨勯潰璇曞湴鐐�,
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勯潰璇曞湴鐐�
    	   	},
    	   	linkPhone: {
    	    	required: "璇疯緭鍏ヤ綘鐨勮仈绯荤數璇�,
    	    	isTel:"璇疯緭鍏ユ纭殑鎵嬫満鍙锋垨搴ф満鍙凤紝搴ф満鏍煎紡濡�10-62555255鎴�10-6255255-鍒嗘満鍙凤紝澶氫釜鐢佃瘽鐢ㄨ嫳鏂囬�鍙烽殧寮�,
    	    	maxlength:"璇疯緭鍏�0瀛椾互鍐呯殑鑱旂郴鐢佃瘽"
    	   	},
    	   	//add nancy
    	   	linkMan:{
    	   		rangelength:"璇疯緭鍏�-16涓瓧绗︾殑鑱旂郴浜�
    	   	},
    	   	//end nancy
    	   	content:{
    	    	maxlength:"璇疯緭鍏�00瀛楃浠ュ唴鐨勮ˉ鍏呭唴瀹�
    	   	}   	   	   	
    	},
    	submitHandler:function(form){
    		$(form).find(":submit").attr("disabled", true);
    		var subject = $('input[name="subject"]',form).val();
    		var interTime = $('input[name="interTime"]',form).val();
    		var interAdd = $('input[name="interAdd"]',form).val();
    		var linkMan = $('input[name="linkMan"]',form).val();
    		var linkPhone = $('input[name="linkPhone"]',form).val();
    		var content = $('textarea[name="content"]',form).val();
    		var deliverId = $('input[name="deliverId"]',form).val();
    		var resubmitToken = $('#resubmitToken').val();
            $.ajax({
            	type:'POST',
            	data:{
            		title:subject,
            		interviewTime:interTime,
            		interAdd:interAdd,
            		linkMan:linkMan,
            		linkPhone:linkPhone,
            		content:content,
            		deliverId:deliverId,
	        		resubmitToken:resubmitToken
            	},
            	url:rctx+'/interview/online.do',
            	dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
    	        jsonp: "jsoncallback",//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
    	        beforeSend: function(){
    	        	$(form).find(":submit").attr("disabled", "disabled");
    			}
            }).done(function(result) {
            	if(null != result.resubmitToken && '' != result.resubmitToken){
            		$('#resubmitToken').val(result.resubmitToken);
            	}
				if(result.state == 1){
					$.colorbox({inline:true, href:$("#noticeInterviewSuccess"),title:"閫氱煡闈㈣瘯"});
				}else if(result.state == 500){
					$.colorbox({inline:true, href:$("#statusChange"),title:"绠�巻鐘舵�鍙樺寲"});
				}
				else{
					alert(result.message);
				}
				$(form).find(":submit").attr("disabled", false);
            }); 
        }  
	});
	/*棰勮閫氱煡闈㈣瘯閭欢 - 鍙戦�*/
	$('#noticeInterviewPreview .btn').bind('click',function(){
		$('#noticeInterviewForm').submit();
	});
	
	//datetimepicker - jqueryUI
	$('#datetimepicker').datetimepicker({
		showMonthAfterYear:true,
		controlType: 'select',
		minDate: 0,
		hourMin: 7,
		hourMax: 23,
		stepMinute: 10,
		dateFormat:"yy-mm-dd"
	});	
	 //瑙ｅ喅閫氱煡闈㈣瘯鎻愮ず璇笉娑堝け
	$('#datetimepicker').focus(function(){
		var length = $('#datetimepicker').val().length;
		if(length!=0){
			$('#datetimepicker').siblings('span').hide();
		}
	});
	// 鐐瑰嚮纭鍒锋柊椤甸潰
	$('#noticeInterviewSuccess .btn').click(function(){
		//$.colorbox.close();
		top.location.href=top.location.href;
	});
	
//==================== wrote by nancy
	$('#mianshiYear').datetimepicker({
		showMonthAfterYear:true,
		controlType: 'select',
		//minDate: 0,
		hourMin: 7,
		hourMax: 23,
		stepMinute: 10,
		dateFormat:"yy-mm-dd"
	});
	/**宸插畨鎺掍负绾夸笅闈㈣瘯**/
	$('.resume_notice_hide').click(function(e){
		$('#hasOfflineNoticeForm input[name="noticeTime"]').val('');
		$('#offlineDeliverId').val($(this).attr('data-deliverid'));
		e.stopPropagation();
		$.colorbox({inline:true, href:$("#hasOfflineNotice"),title:"鏍囨敞涓衡�宸插畨鎺掗潰璇曗�"});
	});
	//鐐瑰嚮宸插畨鎺掗潰璇曠殑寮圭獥鍏抽棴鎸夐挳鏃讹紝宸插畨鎺掗潰璇曞拰鍙戦潰璇曢�鐭ユ妗嗛殣钘�
	$('#colorbox').on('click','#cboxClose',function(){
		if($(this).siblings('#cboxLoadedContent').children('div').attr('id') == 'hasOfflineNotice'){
			$('.send_notice_tips').hide();
		}
	});
	$('#hasOfflineNoticeForm').validate({
		focusInvalid:false,
		rules: {
			noticeTime: {
    	    	required: true
    	   	}
    	},
    	messages: {
    		noticeTime: {
    	    	required: "璇烽�鎷╅潰璇曟椂闂�
    	   	}
    	},
    	submitHandler:function(form){
    		var _form = $(form);
    		_form.find(":submit").attr("disabled", "disabled");
    		var relationId = $('#offlineDeliverId').val();
    		var interviewTime = $('#hasOfflineNotice input[name="noticeTime"]').val();
    		$.ajax({
    			type:'post',
    			url:rctx+'/interview/offline.json',
    			data:{relationId:relationId,interviewTime:interviewTime},
    			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
    	        jsonp: "jsoncallback",//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
    			beforeSend: function(){
    				_form.find(":submit").attr("disabled", "disabled");
    			}	
    		}).done(function(result){
    			if(result.state == 1){
    				top.location.href=top.location.href;
    			}else if(result.state == 500){
					$.colorbox({inline:true, href:$("#statusChange"),title:"绠�巻鐘舵�鍙樺寲"});
				}else{
    				alert(result.message);
    			}
    			_form.find(":submit").attr("disabled", false);
    		});
    	}
	});
	/*$('#hasOfflineNotice .confirm_remarkBtn').click(function(){
		var relationId = $('#offlineDeliverId').val();
		var interviewTime = $('#hasOfflineNotice input[name="noticeTime"]').val();
		$.ajax({
			type:'post',
			url:rctx+'/interview/offline.json',
			data:{relationId:relationId,interviewTime:interviewTime},
			dataType : "jsonp",//鏁版嵁绫诲瀷涓簀sonp  
	        jsonp: "jsoncallback"//鏈嶅姟绔敤浜庢帴鏀禼allback璋冪敤鐨刦unction鍚嶇殑鍙傛暟
		}).done(function(result){
			if(result.state == 1){
				top.location.href=top.location.href;
			}else{
				alert(reusme.message);
			}
		});
	});*/
	
	$('#hasOfflineNotice .cancel').click(function(){
		$('.send_notice_tips').hide();
		$.colorbox.close();
		$('#hasOfflineNoticeForm input[name="noticeTime"]').siblings("span.error").hide();
		$('#hasOfflineNoticeForm input[name="noticeTime"]').val('');
	});
	
	//鐐瑰嚮绾夸笂閫氱煡闈㈣瘯銆佸凡瀹夋帓闈㈣瘯寮圭獥鐨勫叧闂寜閽椂锛屽皢閫夋嫨鏃堕棿鐨刬nput娓呯┖
	$('#colorbox').on('click','#cboxClose',function(){
		if($(this).siblings('#cboxLoadedContent').children('div').attr('id') == 'noticeInterview'){
			$('#noticeInterview input[name="interTime"]').val('');
		}
	});
	$('#colorbox').on('click','#cboxClose',function(){
		if($(this).siblings('#cboxLoadedContent').children('div').attr('id') == 'hasOfflineNotice'){
			$('#hasOfflineNotice input[name="noticeTime"]').val('');
		}
	});
	
//==================== wrote by jason
	//搴曡竟鏍�
	(function(){
		var element = $(".message_box");
		if(L.cookie('msg_box') == null){
			element.hide();
		}else{
			element.slideDown(600);
		}
		$(".msg_delete").on("click",function(event){
	        L.cookie('msg_box','box',{expires:365}) ;
			event.stopPropagation();
			element.fadeOut(200);
		})
	})();
	var resume_num = 0;
	var timer = null;
	$("#resume_select").bind("click",function(e){
		e.stopPropagation();
		if(resume_num==1){
			$(this).find("em").css("transform","rotate(0deg)");
			$(".resume_notice_hide").css({borderBottomRightRadius:'2px',borderBottomLeftRadius: '2px'});
			$(".resume_notice_hide").stop().animate({top:'-12px'}, 'normal');
			resume_num=0;	
		}else{
			$(this).find("em").css("transform","rotate(180deg)");
			$(".resume_notice_hide").css({borderBottomRightRadius:0,borderBottomLeftRadius: 0});
			$(".resume_notice_hide").stop().animate({top:'-45px'}, 'normal');
			resume_num++;
		}
	});
	
	$(".msg_delete").on("click",function(event){
        L.cookie('msg_box','box',{expires:365}) ;
		event.stopPropagation();
		element.fadeOut(200);
	})
	
	//document缁戝畾浜嬩欢 ==銆嬬偣鍑荤綉椤典换鎰忓湴鏂癸紝鏀惰捣鑷畾涔変笅鎷�
	$(document).click(function(){
		if(resume_num == 1){
			$("#resume_select").find("em").css("transform","rotate(0deg)");
			$(".resume_notice_hide").css({borderBottomRightRadius:'2px',borderBottomLeftRadius: '2px'});
			$(".resume_notice_hide").stop().animate({top:'-12px'}, 'normal');
			resume_num=0;
		}
	});	
	 
	//涓嶅悎閫傛鍗曢�
	$(document).on("click",".checkbox input",function(){
		if($(this).attr('checked')){
			$(this).removeAttr('checked');
			$(this).siblings('i').fadeOut(200);
		}else{
			$(this).attr('checked','checked');
			$(this).siblings('i').fadeIn(200);
		}
		return false;
	});	
});

